//
//  MeEachElementdBtn.m
//  EFHealth
//
//  Created by 舒鹏 on 16/7/4.
//  Copyright © 2016年 ef. All rights reserved.
//

#import "HomeNavButton.h"

@interface HomeNavButton ()

@property(nonatomic,strong)UIImageView *imgView;
@property(nonatomic,strong)UILabel *titleL;

@end

@implementation HomeNavButton

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    
    if (self) {
        _imgView = [[UIImageView alloc] init];
        [self addSubview:_imgView];
        
        _titleL = [[UILabel alloc]init];
        _titleL.textColor = kTitleColor_black;
        _titleL.textAlignment = NSTextAlignmentCenter;
        _titleL.font = kFontMimi;
        [self addSubview:_titleL];

    }
    
    return self;
}

- (void)setHimgName:(NSString *)himgName{
    [_imgView sd_setImageWithURL:[NSURL URLWithString:himgName] placeholderImage:kDefaultImage];
    [_imgView setCornerRedius:28];
}

- (void)setTitleName:(NSString *)titleName{

    _titleName = titleName;
    _titleL.text = titleName;
}

- (void)layoutSubviews{
    
    _imgView.frame = CGRectMake((self.width-56)/2 , 0, 56, 56);
    _imgView.top = (self.height-50-kEdgeWidth-20)/2;
    
    _titleL.frame = CGRectMake(0, _imgView.bottom+kEdgeWidth, self.width, 20);
    
}


-(void)setHighlighted:(BOOL)highlighted
{
    if (self.highlighted != highlighted)
    {
        [super setHighlighted:highlighted];

        if (highlighted){
            self.backgroundColor = kColorDefultEdge;
        }
        else{
            self.backgroundColor = kColorDefultCell;
        }
    }
}

-(void)setGlowsWhenHighlighted:(BOOL)glowsWhenHighlighted
{
    if (self.glowsWhenHighlighted != glowsWhenHighlighted)
    {
        _glowsWhenHighlighted = glowsWhenHighlighted;
        
        self.adjustsImageWhenHighlighted = !self.glowsWhenHighlighted;
    }
}

@end
